package com.jvyou.thread.d05priority;

/**
 * @author 橘柚
 * @version 1.0-SNAPSHOT
 * @Date 2024/7/30 17:09
 * @Description
 */
public class PriorityTest implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println(Thread.currentThread().getName() + ":" + i);
        }
    }
    public static void main(String[] args) {
        PriorityTest priorityTest = new PriorityTest();
        Thread thread1 = new Thread(priorityTest, "线程1");
        Thread thread2 = new Thread(priorityTest, "线程2");
        // 修改线程的优先级
        thread1.setPriority(Thread.MIN_PRIORITY);
        thread2.setPriority(Thread.MAX_PRIORITY);
        // 启动线程
        thread1.start();
        thread2.start();
    }
}
